from pyecharts.charts import Bar
from pyecharts import options as opts
from pyecharts.globals import ThemeType
from Test.dataSource.Data import data
title = ['新增确诊', '累计确诊', '累计死亡', '累计治愈']
bar = (
    Bar(init_opts=opts.InitOpts(theme=ThemeType.LIGHT, width="700px", height="700px",
                                animation_opts=opts.AnimationOpts(animation_delay=1000,
                                                                  animation_easing="elasticOut")), )  # 初始动画的缓动效果。
        .add_xaxis(data["region"].to_list())
        .add_yaxis("NewConfirmedCases", data["NewConfirmedCases"].to_list())
        .add_yaxis("NewlyAsymptomatic", data["NewlyAsymptomatic"].to_list())
        .add_yaxis("CumulativeDiagnosis", data["CumulativeDiagnosis"].to_list())
        .set_global_opts(
        toolbox_opts=opts.ToolboxOpts(orient="horizontal", pos_left='13%', pos_top='5%'),
        title_opts=opts.TitleOpts(title="各省市地区情况", title_textstyle_opts=opts.TextStyleOpts(color='#CCFFFF', )),
        yaxis_opts=opts.AxisOpts(name="病例数", axislabel_opts=opts.LabelOpts(formatter="{value}/例")),
        xaxis_opts=opts.AxisOpts(name="地区"),
        legend_opts=opts.LegendOpts(pos_left='30%'),
        datazoom_opts=opts.DataZoomOpts(orient="horizontal", type_='inside', ),  # 组件类型：里面
    )
        .set_series_opts(
        itemstyle_opts={  # 形成圆柱效果
            "normal": {
                "barBorderRadius": [30, 30, 30, 30],
                "shadowColor": "rgb(0, 160, 221)",
            }
        },
        label_opts=opts.LabelOpts(is_show=False, ),  # 标签配置项

    )
)
bar.render("../TestHTML/TestHtml-b/bar.html")